package leetcode.动态规划;

public class 比位特计数338 {
    public int[] countBits(int n) {
        int[] res = new int[n + 1];
        for(int i = 1;i<= n;i++){  //注意要从1开始，0不满足
            res[i] = res[i & (i - 1)] + 1;
        }
        return res;

    }
}
